<?php

class Cascade_AtomController extends Zend_Controller_Action 
{
	public $slug;
	public $data;
	
	public function handleAction()
	{
		$request = $this->getRequest();
		
		switch ($this->getRequest()->getMethod()) {
			case 'GET':
				if ($request->getParam('key') != null) {
					$this->getRequest()->setActionName("view");
					$this->view($request->getParam('key'));
				} else {
					$this->getRequest()->setActionName("showList");
					$this->showList();
				}
			break;
			case 'POST':
				$this->slug = $this->getRequest()->getHeader("slug");
				$this->data = new SimpleXMLElement($this->getRequest()->getRawBody());
				$this->getRequest()->setActionName("create");
				$this->create();
			break;
			case 'PUT':
				$this->data = new SimpleXMLElement($this->getRequest()->getRawBody());
				$this->getRequest()->setActionName("update");
				$this->update($request->getParam('key'));
			break;
			case 'DELETE':
				$this->getRequest()->setActionName("delete");
				$this->delete($request->getParam('key'));
			break;
		}
	}
	
	protected function errorNotFound()
	{
		throw new Zend_Controller_Dispatcher_Exception('Page not found');
	}
	
	public function showList()
	{
		
		//$this->getResponse()->setException()
	}
	
	public function create()
	{
		
	}
	
	public function view($key)
	{
		
	}
	
	public function update($key)
	{
		
	}
	
	public function delete($key)
	{
		
	}

	/**
	 * Return the Request object
	 *
	 * @return Zend_Controller_Request_Http
	 */
	public function getRequest()
	{
		return $this->_request;
	}
}
